package com.gaowl.yygh.oss.controller;

import com.gaowl.yygh.commom.result.Result;
import com.gaowl.yygh.oss.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @program: appointment-register
 * @description: 文件服务控制器类
 * @author: gaowl@stu.jiangnan.edu.cn
 * @create: 2021-04-07 14:07
 **/
@RestController
@RequestMapping("/api/oss/file")
public class FileApiController {

    @Autowired
    private FileService fileService;

    /**
    * @Description: 上传文件到阿里云oss
    * @Param: file 待上传的文件
    * @return:  文件上传到阿里云后的访问地址
    * @Author: gaowl@stu.jiangnan.edu.cn
    * @Date: 2020/04/07
    */
    @PostMapping("fileUpload")
    public Result fileUpload(MultipartFile file){
        String url = fileService.upload(file);
        return Result.ok(url);
    }
}
